package com.allqj.sfx.ddd.member.interfaces.restful.admin;

import com.allqj.sfx.application.dto.DictDTO;
import com.allqj.sfx.application.dto.TableColumnDTO;
import com.allqj.sfx.ddd.member.application.dto.AdminUserLoginDTO;
import com.allqj.sfx.ddd.member.application.service.AdminUserApplicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author sjw
 * @className UserController
 * @date 2022/7/20 9:24
 * @description: 用户
 */

@Api(tags = "会员管理-管理端-用户管理：登录、注册等")
@RestController
@RequestMapping("/v1/member/admin/user")
public class AdminUserController {

    private final AdminUserApplicationService adminUserApplicationService;

    public AdminUserController(AdminUserApplicationService adminUserApplicationService) {
        this.adminUserApplicationService = adminUserApplicationService;
    }

    @ApiOperation(value = "管理端-用户管理-用户登录")
    @PostMapping("/login")
    public String login(@RequestBody AdminUserLoginDTO loginDTO) {
        loginDTO.validate();
        return adminUserApplicationService.login(loginDTO);
    }

    @ApiOperation(value = "管理端-用户管理-列表表头")
    @GetMapping("/pageHeader")
    public List<TableColumnDTO> pageHeader() {
        return adminUserApplicationService.pageHeader();
    }


    @ApiOperation(value = "管理端-用户管理-用户单位字典")
    @GetMapping("/agency")
    public List<DictDTO> agency() {
        return adminUserApplicationService.agency();
    }
}
